package com.neuedu.his.generator;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 项目：      his
 * 类名:       TableColumn
 * 创建时间：  2023/12/7 15：38
 * 描述 :
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TableColumn {
    String columnName ;
    String ordinalPosition;
    String dataType ;
    String columnKey;
    String columnComment;


    public String getEntityPropName(){
        String propName = "";
        if(columnName.contains("_")){
            String split[] = columnName.split("_");
            propName = split[0]      +   split[1].substring(0,1).toUpperCase() +split[1].substring(1,split[1].length());
        }else{
            propName = columnName;
        }

        return propName;
    }


    public String getJavaType(){


        String javaType = "";
        switch (dataType){
            case "varchar":
            case "text":
                javaType = "String";
                break;
            case "bigint":
                javaType = "Long";
                break;
            case "int":
                javaType = "Integer";
                break;
            case "decimal":
            case "float":
            case "double":
                javaType = "Double";
                break;
            case "date":
            case "datetime":
                javaType = "Date";
                break;
            default:
                javaType = "String";
        }


        return  javaType;
    }






}
